package lianxi;

import java.util.ArrayList;

public class demo9 {

    public class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }

    class Solution {
        public boolean isPalindrome(ListNode head) {
           if (head==null){
               return false;
           }
            ArrayList<Integer> arrayList=new ArrayList<>();
           ListNode curnode=head;
           while (curnode!=null){
               arrayList.add(curnode.val);
               curnode=curnode.next;
           }
           int start=0;
           int end=arrayList.size()-1;
           while (start<end){
               if (arrayList.get(start).compareTo(arrayList.get(end))<0){
                    return false;
               }
               start++;
               end--;
           }
           return true;

    }
}}
